package problem06;

import java.util.Scanner;

/**
 * 原始的汉诺塔问题
 * @author Administrator
 *
 */
public class Hanio {

	private static void move(int n,String start,String end){
		System.out.println("Move " + n + " from "+start + " to " + end);
	}
	
	public static int HanioMain(int n,String start,String mid,String end,int step){
		if(n==1){
			move(n, start, end);
			step++;
		}else{
			step=HanioMain(n-1, start, end, mid,step);
			move(n, start, end);
			step++;
			step=HanioMain(n-1, mid, start, end,step);
		}
		return step;
	}
	public static void main(String[] args) {
		int n; 
		String start;
		String mid;
		String end;
		System.out.println("请输入原始的圆盘数，以及初始，辅助和目标柱：\n比如：3 left mid right");
		Scanner scanner = new Scanner(System.in);
		String[] str = scanner.nextLine().split("\\s+");
		n=Integer.valueOf(str[0]);
		start = str[1];
		mid=str[2];
		end = str[3];
		
		int step = Hanio.HanioMain(3, start, mid, end,0);
		System.out.println("It will move "+step+" steps");
	}
}
